<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站后台管理系统</title>
<meta name="keywords" content="">
<meta name="description" content="">
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="css/ie6.css"/>
<![endif]-->
<link rel="stylesheet" type="text/css"  href="../../../../public/layui/css/layui.css">
<link href="../../../../public/admin/css/style_v2.0.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/layui/css/layui.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/style_v2.0.css" />
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/layui/layui.js"></script>
</head>
<body>
<div class="position mt10">当前位置：<a href="{:U('Index/main')}">后台首页</a>  > <a href="{:U('Sms/sendsms')}">短信设置</a>  </div>
<div id="container">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>短信测试</legend>
</fieldset>
<!--高级搜索-->
<div class="c"></div>
<form id="form2" name="form2" method="post" action="#"> 
<div class="layui-form">
    <table class="layui-table">
    <tr>
	  <td width="20%" align="right">手机号：</td>
	  <td width="80%">
      <span class="table_span" style="width:300px; float:left;"><input name="phone" type="text" id="phone" class="layui-input"></span>
      <!--<span class="table_txt" id="phone_tips">ok</span>-->
      <span class="table_txt" id="times"></span>
      <span class="table_txt" id="send">发送验证码</span>
      </td>
    </tr>
    <tr>
	     <td align="right">验证码：</td>
	     <td>
            <span  class="table_span" style="width:300px; float:left;"><input type="text" id="verify" name="verify"  class="layui-input"></span>
            <span class="table_txt" id="chk_verify"></span></td>
    </tr>
    <tr> 
      <td align="right"></td>
	  <td valign="middle">
		<input type="submit" name="Submit" id="login" value="确&nbsp; &nbsp;定" class="layui-btn" >
	  </td>
	</tr>
    </table>
</div> 
</form>
</div>
</body>
</html>
<script type="text/javascript">
    $('#login').attr({'disabled':'false','title':'禁止提交'}).css({'background-Color':'#ccc'});
    //发送验证码
        function test(){
            var i=60;
            var timer=setInterval(function(){
                i--;
                $("#times").text(i);
                if(i==0){
                    $("#send").css("display","block");
                    $("#times").css("display","none");
                    clearInterval(timer);
                    $("#times").text(60);
                }
            },1000);
        };

        $('#send').click(function(){
				var phone = $('#phone').val();
				//var evaluation_id = $("#evaluation").val();
				$.ajax({
					url: "__CONTROLLER__/send_message",
					data: {'phone': phone },
					dataType: "json",
					type: "POST",
					success: function(data) {
						if (data == 2) {
							$('#phone_tips').html('手机号已注册！');
						}else{
							$("#send").css("display","none");
							$("#times").css("display","block");
						   test();
						}
						//console.log(data);
					}
				});

		});

		//判断验证码是否正确
		$('#verify').keyup(function(){
			var verify = $('#verify').val();
			var phone  = $('#phone').val();
			$.ajax({
				url: "__CONTROLLER__/checkSMSCode",
				data: {'verify': verify,'phone': phone },
				dataType: "json",
				type: "POST",
				success: function(data) {
							if (data == 'ok') {
								$('#login').attr({'disabled':'true','title':'登录'}).css({'background-Color':'#009688'});
								$("#chk_verify").html("<font color=#009688>ok</font>")
							}else if (data == 'nos'){
							   $('#login').attr({'disabled':'false','title':'禁止提交'}).css({'background-Color':'#ccc'});
							   $("#chk_verify").html("<font color=red>验证码超时</font>")
							}else if(data == 'no'){
							   $('#login').attr({'disabled':'false','title':'禁止提交'}).css({'background-Color':'#ccc'});
							   $("#chk_verify").html("<font color=red>验证码错误</font>")
							}
							//console.log(data);
				}
			});

		});


    </script>
<script>
//Demo
layui.use(['form','laydate'], function(){
 var form = layui.form
  ,laydate = layui.laydate;
   var active = {
       notice: function(){
		  layer.open({
			type: 1
			,title: '新增虚拟主机' //不显示标题栏
			,closeBtn: 2
			,area: ['680px','550px']
			,shade: 0.4
			,id: 'LAY_layuipro' //设定一个id，防止重复弹出
			//,btn: ['提交', '关闭']
			,btnAlign: 'c'
			,moveType: 1 //拖拽模式，0或者1
			,content: $("#host_add"),
            })
       }
   }
   
    $('.layui-btn-group .layui-btn').on('click', function(){
		var othis = $(this), method = othis.data('method');
		active[method] ? active[method].call(this, othis) : '';
	  });

  //监听提交
  form.on('submit(btnDel)', function(data){
    //layer.msg(JSON.stringify(data.field));
	title: '最终的提交信息'
	return true;
  });
  
  laydate.render({
    elem: '#inputtime'
	,type: 'datetime'
  });
  laydate.render({
    elem: '#hoststart'
  });
  laydate.render({
    elem: '#hostend'
  });
  
});
</script>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>